package java_DesignPattern.BehavioralPattern.IteratorPattern;

import java.util.ArrayList;
import java.util.List;

/**
 * 学生容器类，实现了容器接口，用于存储和遍历学生列表
 */
public class StudentContext implements Context<Student> {

    private List<Student> list = new ArrayList<>();

    @Override
    public void add(Student student) {
        list.add(student);
    }

    @Override
    public void remove(Student student) {
        list.remove(student);
    }

    @Override
    public Iterator getIterator() {
        return new StudentIterator(list);
    }
}
